package com.label.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.label.entity.Log;
import com.label.entity.User;
import com.label.mapper.LabelsMapper;
import com.label.mapper.LogMapper;
import com.label.service.LogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Jianhua
 * @since 2022-03-27
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements LogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public Page pageList(Page page, Log log){
        if (page==null){
            page =new Page();
        }
        QueryWrapper wrapper=new QueryWrapper();
        if (log!=null&& StringUtils.isNotEmpty(log.getOperationType())){
            wrapper.like("idlog",log.getOperationType());
        }
        return super.page(page,wrapper);
    }
    @Override
    public boolean logsave(Log log){
        int i=logMapper.insert(log);
        if (i>0){
            return true;
        }else return false;
    }
    @Override
    public Page getBylike(Page page, String key){
        if (page==null){
            page =new Page();
        }
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.like("username",key);
        wrapper.or();
        wrapper.like("operationType",key);
        wrapper.or();
        wrapper.like("operationtime",key);
        wrapper.or();
        wrapper.like("patientname",key);
        wrapper.or();
        wrapper.like("labelname",key);
        wrapper.or();
        wrapper.like("labelid",key);
        return super.page(page,wrapper);
    }
}
